

$(function(){
	
	var id=$("#id").val();
	$("#confirmAddArticle").click(function(){
		var title=$("#title").val();
		var author=$("#author").val();
		var atype=$("#atype").val();
		var content=editor.html();
		content=encodeURI(content);
		var pic;
		console.log(content);
		$.ajaxFileUpload({
			  url:rootPath+"/article/addOrUpdateArticle",//需要链接到服务器地址   
			  type:'post',
			  data:{'title':title,'author':author,'atype':atype,'content':content,'id':id},
		      secureuri:false,  
		      fileElementId:"pic",//文件选择框的id属性  
		      dataType: 'JSON',   //json 
		      success: function (data) {  
		    	  var reg = /<pre.+?>(.+)<\/pre>/g;  
		    	  var result = data.match(reg);  
		    	  data = RegExp.$1;
		    	  data=toJson(data);
		    	  if (data.resultSuccess) {
		    		  layer.msg('添加成功');
					} else {
						layer.alert('添加失败！', 3);
					}
		      }
		})
	})
})
function getContent() {
    var arr = [];
    arr.push(ue.getContent());
    arr.join("\n");
    return encodeURIComponent(arr.toString());
}
function toJson(str){
  var json = eval('(' + str + ')');
  return json;
}
